<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('学员编辑')" />
    <th:block th:include="include :: select2-css" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="gray-bg">
    <form class="form-horizontal" id="form-baoban-add"  th:object="${student}">
    <input id="id" name="id" th:field="*{id}" type="hidden">
    <div class="wrapper wrapper-content">
         <div class="row">
             <div class="col-sm-12">
                 <div class="ibox float-e-margins">
                     <div class="ibox-title">
                         <h3>学员信息</h3>
                     </div>
                     <div class="ibox-content">
                         <div class="row">
                             <div class="col-sm-3">
                                 <div class="form-group">
                                     <label class="col-xs-4 control-label is-required">学员姓名：</label>
                                     <div class="col-xs-8">
                                         <input name="name" th:field="*{name}" id="name" placeholder="请输入学员姓名" class="form-control" type="text" maxlength="100" required>
                                     </div>
                                 </div>
                             </div>
                             <div class="col-sm-3">
                                 <div class="form-group">
                                     <label class="col-xs-4 control-label is-required">性别：</label>
                                     <div class="col-xs-8">
                                         <select name="sex" class="form-control" th:field="*{sex}">
                                             <option value="1">女</option>
                                             <option value="2">男</option>
                                         </select>
                                     </div>
                                 </div>
                             </div>
                         </div>
                         <div class="row">
                             <div class="col-sm-3">
                                 <div class="form-group">
                                     <label class="col-xs-4 control-label is-required">家长姓名：</label>
                                     <div class="col-xs-8">
                                         <input th:field="*{parentName}" name="parentName" placeholder="请输入家长姓名" class="form-control" type="text" maxlength="100" required>
                                     </div>
                                 </div>
                             </div>
                             <div class="col-sm-3">
                                 <div class="form-group">
                                     <label class="col-xs-4 control-label is-required">家长手机：</label>
                                     <div class="col-xs-8">
                                         <input th:field="*{parentPhone}" name="parentPhone" placeholder="请输入家长手机" class="form-control" type="text" maxlength="20" required>
                                     </div>
                                 </div>
                             </div>
                             <div class="col-sm-3">
                                 <div class="form-group">
                                     <label class="col-xs-4 control-label">招生来源：</label>
                                     <div class="col-xs-8">
                                         <select name="fromType" class="form-control" th:field="*{fromType}">
                                             <option value="0">咨询</option>
                                             <option value="1">活动</option>
                                             <option value="2">老带新</option>
                                         </select>
                                     </div>
                                 </div>
                             </div>
                             <div class="col-sm-3">
                                 <div class="form-group">
                                     <label class="col-xs-4 control-label">介绍人：</label>
                                     <div class="col-xs-8">
                                         <input th:field="*{recommendUser}" name="recommendUser" class="form-control" type="text" maxlength="20">
                                     </div>
                                 </div>
                             </div>
                         </div>
                         <div class="row">
                             <div class="col-sm-3">
                                 <div class="form-group">
                                     <label class="col-xs-4 control-label">备注：</label>
                                     <div class="col-xs-8">
                                         <textarea th:field="*{remark}" id="remark" name="remark" rows="3" class="form-control"></textarea>
                                     </div>
                                 </div>
                             </div>
                         </div>
                         <div class="row">
                             <div class="col-sm-3">
                                 <div class="form-group">
                                     <label class="col-xs-4 control-label">学员生日：</label>
                                     <div class="col-xs-8">
                                         <input th:field="*{birthday}" id="birthday" name="birthday" placeholder="点击选择日期" class="form-control" type="text" maxlength="100">
                                     </div>
                                 </div>
                             </div>
                             <div class="col-sm-3">
                                 <div class="form-group">
                                     <label class="col-xs-4 control-label">身份证号：</label>
                                     <div class="col-xs-8">
                                         <input th:field="*{idCard}" name="idCard" placeholder="请输入身份证号" class="form-control" type="text" maxlength="100" >
                                     </div>
                                 </div>
                             </div>
                             <div class="col-sm-3">
                                 <div class="form-group">
                                     <label class="col-xs-4 control-label">公立学校名称：</label>
                                     <div class="col-xs-8">
                                         <input th:field="*{schoolName}" name="schoolName" placeholder="请输入公立学校名称" class="form-control" type="text" maxlength="100" >
                                     </div>
                                 </div>
                             </div>
                             <div class="col-sm-3">
                                 <div class="form-group">
                                     <label class="col-xs-4 control-label">公立学校年级：</label>
                                     <div class="col-xs-8">
                                         <input th:field="*{schoolGrade}" name="schoolGrade" placeholder="请输入公立学校年级" class="form-control" type="text" maxlength="100" >
                                     </div>
                                 </div>
                             </div>
                         </div>
                         <div class="row">
                             <div class="col-sm-3">
                                 <div class="form-group">
                                     <label class="col-xs-4 control-label">公立学校班级：</label>
                                     <div class="col-xs-8">
                                         <input th:field="*{schoolClass}" name="schoolClass" placeholder="请输入公立学校班级" class="form-control" type="text" maxlength="100">
                                     </div>
                                 </div>
                             </div>
                             <div class="col-sm-3">
                                 <div class="form-group">
                                     <label class="col-xs-4 control-label">家庭住址：</label>
                                     <div class="col-xs-8">
                                         <input th:field="*{address}" name="address" placeholder="请输入家庭住址" class="form-control" type="text" maxlength="100" >
                                     </div>
                                 </div>
                             </div>
                         </div>

                     </div>
                 </div>
             </div>
         </div>

        <div class="row">
            <div class="col-sm-12">
                     <div class="ibox-content">
                         <div class="row">
                             <div class="col-sm-12 table-striped" style="text-align: center;">
                                 <!--<table id="bootstrap-table"></table>-->
                                 <button type="button" class="btn btn-w-m btn-success" onclick="submitHandler()">确定</button>
                                 <button type="button" class="btn btn-w-m btn-white" onclick="cancel()">取消</button>
                             </div>
                         </div>
                     </div>
                 </div>
             </div>
         </div>

    </div>
    </form>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: select2-js" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        $(function() {
            layui.use('laydate', function () {
                var laydate = layui.laydate;
                laydate.render({
                    elem: '#birthday'
                });
            })
        })

        var prefix = ctx + "kfzx/student";
        $("#form-baoban-add").validate({
            onkeyup: false,
            rules:{
                name:{
                    remote: {
                        url: ctx + "kfzx/student/checkNameUnique",
                        type: "post",
                        dataType: "json",
                        data: {
                            "name" : function() {
                                return $.common.trim($("#name").val());
                            },
                            "id" : function() {
                                return $.common.trim($("#id").val());
                            }
                        },
                        dataFilter: function(data, type) {
                            return $.validate.unique(data);
                        }
                    }
                },
                orderNum:{
                    digits:true
                },
            },
            messages: {
                "name": {
                    remote: "名称已存在！"
                }
            },
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                var data = $("#form-baoban-add").serialize();
                $.operate.save("/kfzx/student/edit",  data);
            }
        }

        function cancel() {
            location.href = prefix;
        }
    </script>
</body>
</html>